{# SPDX-License-Identifier: Apache-2.0 -#}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="google" content="notranslate">

    <title>{% block title_base %}{% block title %}{% endblock %}{% if self.title() %} · {% endif %}Admin · {{ request.registry.settings['site.name'] }}{% endblock %}</title>

    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">

    <link rel="icon" href="{{ request.static_path('warehouse:static/dist/images/favicon.ico') }}" type="image/x-icon">

    <link rel="stylesheet" href="{{ request.static_url('warehouse.admin:static/dist/css/all.css') }}">

    {% if devPyPI %}
    <script src="{{ request.registry.settings.get("livereload.url") }}/livereload.js"></script>
    {% endif %}
  </head>

<body class="hold-transition sidebar-mini">

<div class="wrapper">
  <!-- Navbar -->
  <nav class="main-header navbar navbar-expand navbar-white navbar-light">
    <!-- Left navbar links -->
    <ul class="navbar-nav">
      <li class="nav-item">
        <a class="nav-link" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars"></i></a>
      </li>
      <li class="nav-item d-none d-sm-inline-block">
        <a href="{{ request.route_path('index') }}" class="nav-link" target="_blank" rel="noopener">
          PyPI Home
        </a>
      </li>

      <li class="nav-item d-none d-sm-inline-block">
        <a href="https://github.com/pypa/pypi-support/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc" class="nav-link" target="_blank" rel="noopener">
          Support Issues
        </a>
      </li>
    </ul>

    <!-- Right navbar links -->
    <ul class="navbar-nav ml-auto">
      <!-- Expand to full screen -->
      <li class="nav-item">
        <a class="nav-link" data-widget="fullscreen" href="#" role="button">
          <i class="fas fa-expand-arrows-alt"></i>
        </a>
      </li>
      <!-- Log Out button -->
      <li class="nav-item">
        <form id="logout" method="POST" action="{{ request.route_path('accounts.logout') }}">
          <input name="csrf_token" type="hidden" value="{{ request.session.get_csrf_token() }}">
        </form>
        <a class="nav-link" data-form-submit="logout" href="{{ request.route_path('accounts.logout') }}" title="Log Out">
          <i class="fa fa-sign-out-alt"></i>
        </a>
      </li>
    </ul>
  </nav>
  <!-- /.navbar -->

  <!-- Main Sidebar Container -->
  <aside class="main-sidebar sidebar-dark-primary elevation-4">
    <!-- Brand Logo -->
    <a href="{{ request.route_path('admin.dashboard') }}" class="brand-link">
      <img src="{{ request.static_path('warehouse:static/dist/images/logo-small.svg') }}" alt="PyPI Logo" class="brand-image">
      <span class="brand-text font-weight-light"><b>Warehouse</b> Admin</span>
    </a>

    <!-- Sidebar -->
    <div class="sidebar">
      <!-- Sidebar user panel (optional) -->
      <div class="user-panel mt-3 pb-3 mb-3 d-flex">
        <div class="image">
          <img src="{{ gravatar(request, request.user.email, size=160) }}" class="img-circle elevation-2" alt="User Image">
        </div>
        <div class="info">
          <a class="d-block" href="{{ request.route_path('admin.user.detail', username=request.user.username) }}">{{ request.user.name|default(request.user.username, true) }}</a>
        </div>
      </div>

      <!-- SidebarSearch Form -->
      <div class="form-inline">
        <div class="input-group" data-widget="sidebar-search">
          <input class="form-control form-control-sidebar" type="search" placeholder="Search" aria-label="Search">
          <div class="input-group-append">
            <button class="btn btn-sidebar">
              <i class="fas fa-search fa-fw"></i>
            </button>
          </div>
        </div>
      </div>

      <!-- Sidebar Menu -->
      <nav class="mt-2">
        <ul class="nav nav-pills nav-sidebar nav-child-indent flex-column" data-widget="treeview" role="menu" data-accordion="false">
          {# TODO: Is there a cleaner way to show/hide the allowed sections? #}
          {% if request.has_permission(Permissions.AdminDashboardSidebarRead) %}
          <li class="nav-item">
            <a href="{{ request.route_path('admin.organization_application.list') }}?q=is%3Asubmitted" class="nav-link">
              <i class="fa fa-sitemap nav-icon"></i> <p>Organization Applications</p>
            </a>
          </li>
          <li class="nav-item">
            <a href="{{ request.route_path('admin.organization.list') }}" class="nav-link">
              <i class="fa fa-sitemap nav-icon"></i> <p>Organizations</p>
            </a>
          </li>
          <li class="nav-item">
            <a href="{{ request.route_path('admin.user.list') }}" class="nav-link">
              <i class="fa fa-user nav-icon"></i> <p>Users</p>
            </a>
          </li>
          <li class="nav-item">
            <a href="{{ request.route_path('admin.macaroon.decode_token') }}" class="nav-link">
              <i class="fa-solid fa-stroopwafel nav-icon"></i> <p>Macaroons</p>
            </a>
          </li>
          <li class="nav-item">
            <a href="{{ request.route_path('admin.ip_address.list') }}" class="nav-link">
              <i class="fa-solid fa-globe nav-icon"></i> <p>IP Addresses</p>
            </a>
          </li>
          <li class="nav-item">
            <a href="{{ request.route_path('admin.project.list') }}" class="nav-link">
              <i class="fa fa-cubes nav-icon"></i> <p>Projects</p>
            </a>
          </li>
          <li class="nav-item">
            <a href="{{ request.route_path('admin.journals.list') }}" class="nav-link">
              <i class="fa fa-book nav-icon"></i> <p>Journals</p>
            </a>
          </li>
          <li class="nav-item menu-closed">
            <a href="#" class="nav-link">
              <i class="nav-icon fa-solid fa-eye"></i>
              <p>
                Observations
                <i class="right fas fa-angle-left"></i>
              </p>
            </a>
            <ul class="nav nav-treeview">
              <li class="nav-item">
                <a href="{{ request.route_path('admin.malware_reports.list') }}" class="nav-link">
                  <i class="nav-icon fa-solid fa-dumpster-fire"></i>
                  <p>Malware Reports</p>
                </a>
              </li>
              <li class="nav-item">
                <a href="{{ request.route_path('admin.quarantine.list') }}" class="nav-link">
                  <i class="nav-icon fa-solid fa-file-shield"></i> <p>Quarantine</p>
                </a>
              </li>
              <li class="nav-item">
                <a href="{{ request.route_path('admin.observations.list') }}" class="nav-link">
                  <i class="nav-icon fa-solid fa-eye"></i>
                  <p>All Observations</p>
                </a>
              </li>
            </ul>
          </li>
          <li class="nav-item menu-closed">
            <a href="#" class="nav-link">
              <i class="nav-icon fa fa-ban"></i>
              <p>
                Prohibition Era
                <i class="right fas fa-angle-left"></i>
              </p>
            </a>
            <ul class="nav nav-treeview">
              <li class="nav-item">
                <a href="{{ request.route_path('admin.prohibited_project_names.list') }}" class="nav-link">
                  <i class="nav-icon fa fa-cubes fa-flip-vertical"></i>
                  <p>Project Names</p>
                </a>
              </li>
              <li class="nav-item">
                <a href="{{ request.route_path('admin.prohibited_user_names.list') }}" class="nav-link">
                  <i class="nav-icon fa fa-user fa-flip-vertical"></i>
                  <p>Usernames</p>
                </a>
              </li>
              <li class="nav-item">
                <a href="{{ request.route_path('admin.prohibited_email_domains.list') }}" class="nav-link">
                  <i class="nav-icon fa fa-envelope fa-flip-vertical"></i>
                  <p>Email Domains</p>
                </a>
              </li>
            </ul>
          </li>
          <li class="nav-item">
            <a href="{{ request.route_path('admin.emails.list') }}" class="nav-link">
              <i class="fa fa-envelope nav-icon"></i> <p>Emails</p>
            </a>
          </li>
          <li class="nav-item">
            <a href="{{ request.route_path('admin.flags') }}" class="nav-link">
              <i class="fa fa-flag nav-icon"></i> <p>Flags</p>
            </a>
          </li>
          {% endif %}
          {# TODO: This is implicitly allowed for PSF Staff #}
          <li class="nav-item">
            <a href="{{ request.route_path('admin.banner.list') }}" class="nav-link">
              <i class="fa fa-quote-right nav-icon"></i> <p>Banners</p>
            </a>
          </li>
          <li class="nav-item">
            <a href="{{ request.route_path('admin.sponsor.list') }}" class="nav-link">
              <i class="fa fa-ad nav-icon"></i> <p>Sponsors</p>
            </a>
          </li>
        </ul>
      </nav>
      <!-- /.sidebar-menu -->
    </div>
    <!-- /.sidebar -->
  </aside>

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            {% block title_header %}<h1 class="m-0">{{ self.title()|default('Dashboard', true) }}</h1>{% endblock %}
          </div><!-- /.col -->
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item">
                <a href="{{ request.route_path('admin.dashboard') }}"><i class="fa fa-tachometer-alt"></i> Dashboard</a>
              </li>
              {% block breadcrumb %}
              {% endblock %}
            </ol>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->

    <!-- Main content -->
    <div class="content">
      <div class="container-fluid">
        <div class="row">
          <div class="col-md-12">
            {% for message in request.session.pop_flash(queue="error") %}
            <div class="alert alert-danger alert-dismissible">
              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>

              {{ message }}
            </div>
            {% endfor %}

            {% for message in request.session.pop_flash() %}
            <div class="alert alert-info alert-dismissible">
              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>

              {{ message }}
            </div>
            {% endfor %}

            {% for message in request.session.pop_flash(queue="success") %}
            <div class="alert alert-success alert-dismissible">
              <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>

              {{ message }}
            </div>
            {% endfor %}

            {% block content %}
            {% endblock content %}
          </div> <!-- /.col -->
        </div> <!-- /.row -->
      </div> <!-- /.container-fluid -->

    </div>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->

  <!-- Main Footer -->
  <footer class="main-footer">
    <!-- To the right -->
    <div class="float-right d-none d-sm-inline">
      Have you in fact got any cheese here at all?
    </div>
    <!-- Default to the left -->
    <strong>&copy; {{ now()|format_date('yyyy') }} <a href="https://www.python.org/psf-landing/" title="PSF" target="_blank" rel="noopener">Python Software Foundation</a>.</strong>
  </footer>
</div>
<!-- ./wrapper -->

<script src="{{ request.static_url('warehouse.admin:static/dist/js/admin.js') }}"></script>

</body>
</html>
